package com.luhui.codereview.listeners

import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.event.EditorMouseEvent
import com.intellij.openapi.editor.event.EditorMouseListener
import com.intellij.openapi.project.Project
import com.luhui.codereview.swing.CodeReviewPanel

/**
 * @author  luhui
 * @date  2019/11/3 0:28
 * @version 1.0
 */
class FileEditorMouseListener(val editor:Editor,val project: Project) : EditorMouseListener {



    override fun mouseEntered(p0: EditorMouseEvent?) {
    }

    override fun mouseClicked(p0: EditorMouseEvent?) {
    }

    override fun mouseExited(p0: EditorMouseEvent?) {
    }

    override fun mousePressed(p0: EditorMouseEvent?) {
    }

    override fun mouseReleased(p0: EditorMouseEvent?) {
       val code = editor.selectionModel.selectedText

        //todo 不要去访问applicaiton业务对象中的属性
        val textarea = CodeReviewPanel.getInstance(project).viewTabTable?.getApplicationContext()?.origCodeTextArea?:return
        textarea.text = code
    }

}